public class Main {
    public static void main(String[] args) {
        String str1 = "";//空字符串
        StringBuilder str2 = new StringBuilder("");
        int time = 10_000;
        //获取时间戳
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < time; i++) {
            str2.append(i);
        }
        long endTime = System.currentTimeMillis();
        System.out.println("时间: " + (endTime - startTime));
        main2(args);
    }
    public static void main2(String[] args) {
        String str1 = "";//空字符串
        StringBuilder str2 = new StringBuilder("");
        int time = 10_000;
        //获取时间戳
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < time; i++) {
            str1 += i;
        }
        long endTime = System.currentTimeMillis();
        System.out.println("时间: " + (endTime - startTime));
    }

    public static void main1 (String[] args) {
        StringBuilder str1 = new StringBuilder("hello");
        str1.append(" world");
        System.out.println(str1);
    }
}
